import firebase_admin
from firebase_admin import credentials, messaging
from django.conf import settings

def send_notification(to, title, body):
    print("To", to)
    if not firebase_admin._apps:
        cred = credentials.Certificate(settings.FCM_FILE_PATH)
        firebase_admin.initialize_app(cred)

    message = messaging.Message(
        notification=messaging.Notification(title=title, body=body),
        token=to,
    )

    messaging.send(message)